//
//  DeviceManager.m
//  KingSelected
//
//  Created by 杨鹏 on 2023/10/27.
//

#import "DeviceManager.h"
#import <sys/utsname.h>
#import <UIKit/UIKit.h>

@implementation DeviceManager

+ (CGFloat)heightForTabbar {
    return 49 + [DeviceManager heightForTabbarExtra];
}

+ (CGFloat)heightForTabbarExtra {
    if (@available(iOS 13.0, *)) {
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowScene = [set anyObject];
        UIWindow *window = windowScene.windows.firstObject;
        return window.safeAreaInsets.bottom;
    } else if (@available(iOS 11.0, *)) {
        UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
        return window.safeAreaInsets.bottom;
    }
    return 0;
}

+ (CGFloat)heightForNaigation {
    return 44 + [DeviceManager heightForStatusBar];
}

+ (CGFloat)heightForStatusBar {
    CGFloat statusBarHeight = 0;
    if (@available(iOS 13.0, *)) {
        UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
        statusBarHeight = statusBarManager.statusBarFrame.size.height;
    }else {
        statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    }
    return statusBarHeight;
}

+ (CGFloat)heightForScreen {
    return [UIScreen mainScreen].bounds.size.height;
}
+ (CGFloat)widthForScreen {
    return [UIScreen mainScreen].bounds.size.width;
}

+ (NSString *)appVersion {
    return @"1.0";
}

@end
